package com.dd.ent.car.ui.user.note;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import com.dd.ent.car.R;
import com.dd.ent.car.ui.BaseActivity;
import com.pp.ent.view.annotation.ContentView;
import com.pp.ent.view.annotation.OnClick;
import com.pp.ent.view.annotation.ViewInject;

import me.iwf.photopicker.widget.TouchImageView;

/**
 * Created by aqu-spring on 17/5/30.
 */
@ContentView(R.layout.activity_image_dialog_layout)
public class ImageDialogActivity extends BaseActivity {
    public final static String IMAGE_PATH = "image_path";

    private String imagePath;
    @ViewInject(R.id.img_album)
    private TouchImageView imgAlbumView;

    public static void startSelf(Context context, String imagePath) {
        Intent intent = new Intent(context, ImageDialogActivity.class);
        intent.putExtra(IMAGE_PATH, imagePath);
        context.startActivity(intent);

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        handleIntent();
        initData();
    }

    private void initData() {
        Glide.with(this).load(imagePath).asBitmap().into(new SimpleTarget<Bitmap>(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                imgAlbumView.setImageBitmap(resource);
            }
        });
    }

    private void handleIntent() {
        Intent intent = getIntent();
        imagePath = intent.getStringExtra(IMAGE_PATH);
    }


    @OnClick({R.id.titlebar_left})
    public void onClick(View view){
        switch (view.getId()){
            case R.id.titlebar_left:
                finish();
                break;
        }
    }

}
